package day03;

/*
@Author: 王少杰
@Date: 2025/1/2
@Time: 15:35
@FileName: TriangleTes.java
@描述:
*/
public class TriangleTes {
    public static void main(String[] args) {
        Triangle triangle = new Triangle();
        triangle.setA(3);
        triangle.setB(4);
        triangle.setC(5);
        System.out.println("三角形的周长为:"+ triangle.getPerimeter());
        System.out.println("三角形的面积为:"+ triangle.getArea());
    }
}
class Triangle {
    private int a, b, c;

    public int getA() {
        return a;
    }

    public void setA(int a) {
        if (a > 0){
            this.a = a;
        }else {
            System.out.println("输入的数据错误");
        }
    }

    public int getB() {
        return b;
    }

    public void setB(int b) {
        if (b > 0){
            this.b = b;
        }else {
            System.out.println("输入的数据错误");
        }
    }

    public int getC() {
        return c;
    }

    public void setC(int c) {
        if (c > 0){
            this.c = c;
        }else {
            System.out.println("输入的数据错误");
        }
    }

    public Triangle() {
    }

    public Triangle(int a, int b, int c) {
        this.a = a;
        this.b = b;
        this.c = c;
    }

    // 计算周长的方法
    public double getPerimeter() {
        return a + b + c;
    }

    public double getArea() {
        return (double) (a + b) / 2;
    }
}